#!/anaconda3/envs/Script/bin python3.8
# -*- coding: utf-8 -*-
# ---
# @Software: PyCharm
# @File: table_service.py
# @Author: AllenFu
# @Institution: NCHU, China
# @E-mail: nchufujianjian@126.com
# @Site: 
# @Time: 11月 27, 2020
# ---
from app import dBSession
from app.models.users import Users
from app.vendor.decorator import classTransaction


class TableService:

    @classTransaction
    def lock(self):
        """ 行级锁 """
        query = dBSession.query(Users).filter(Users.id == 34).with_for_update().first();
        print('SQL : %s'% str(query))
        dBSession.execute("select sleep(10)")